<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Page extends Controller_Common {

	public $template='layout/index';

	public function action_one() {
		$page = ORM::factory('Pages')->getOne($this::$postfix, $this->request->param('id'));

		if (!empty($page)) {
			$this->buildCarcas();
			$this->template->title = $page->title.' - '.$this->sitetext['comapny_name']['_value'];
			$this->template->description = $page->meta_description;

			$this->template->content = View::factory('pages/page', array(
				'page' => $page,
				'left_menu' => Model::factory('Menu')->get_by_location(1),
				'right_banners' => Model::factory('Banners')->get_right(),
				'bot_banner' => Model::factory('Banners')->get_bot(),
				'partners' => Model::factory('Partners')->get_all(),
				'breadcrumbs' => View::factory('pieces/breadcrumbs', array(
					'breadcrumbs' => array(
						array('active' => 0, 'title' => 'Главная', 'link' => '/'),
						array('active' => 1, 'title' => $page->title, 'link' => '/page/'.$page->link)
					)
				)),
			));
		} else {
			throw HTTP_Exception::factory(404, ':text', array(
				':text' => $this->sitetext['not_found']['_value']
			));
		}

	}
}